#ifndef DISCOVER_H
#define DISCOVER_H

#include "../QCommon/user.h"
#include <vector>

#define REFRESH_INTERVAL 5
#define RETRIEVE_INTERVAL 3
#define NOTIFY_INTERVAL 2
using namespace std;

class Discover
{
private:
    vector<User> *users;
    vector<bool> *flags;

    friend void* check_online(void*);
public:
    Discover();
    ~Discover();
    void setOnline(User &);
    void setOffline(User &);
	int search_user_index(string ip, int pid);
	User search_user(int index);
    vector<User> getOnlineUsers();
};

struct Address
{
    char ip_addr[128];
    char broadcast_addr[128];
};

class Notify
{
private:
    friend void* broadcast(void*);
public:
    User *user;
    Address *address;
    Notify();
    ~Notify();
    void setUser(User &u);
    const User& getUser() const;
};

#endif
